2023-05-09 13:13:47 +04:00
|
|
|
|
using ConstructionCompanyContracts.BindingModels;
|
2023-05-09 22:06:53 +04:00
|
|
|
|
using ConstructionCompanyContracts.ViewModels;
|
2023-05-09 13:13:47 +04:00
|
|
|
|
using ConstructionCompanyDataModels.Models;
|
|
|
|
|
using MongoDB.Bson;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ConstructionCompanyMongoDBImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Material : IMaterialModel
|
|
|
|
|
{
|
|
|
|
|
public string MaterialName { get; private set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public int Quantity { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public static Material? Create(MaterialBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Material()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
MaterialName = model.MaterialName,
|
|
|
|
|
Quantity = model.Quantity,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static BsonDocument? CreateBSON(MaterialBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new BsonDocument
|
|
|
|
|
{
|
|
|
|
|
{"_id", model.Id},
|
|
|
|
|
{"materialName", $"{model.MaterialName}"},
|
|
|
|
|
{"quantity", $"{model.Quantity}" }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static BsonDocument? UpdateBSON(MaterialBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new BsonDocument
|
|
|
|
|
{
|
|
|
|
|
{"_id", model.Id},
|
|
|
|
|
{"materialName", $"{model.MaterialName}"},
|
|
|
|
|
{"quantity", $"{model.Quantity}" }
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-05-09 22:06:53 +04:00
|
|
|
|
|
|
|
|
|
public MaterialViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
MaterialName = MaterialName,
|
|
|
|
|
Quantity = Quantity
|
|
|
|
|
};
|
2023-05-09 13:13:47 +04:00
|
|
|
|
}
|
|
|
|
|
}
|