64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using ConstructionCompanyContracts.BindingModels;
|
|
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 Position : IPositionModel
|
|
{
|
|
public string PositionName { get; private set; } = string.Empty;
|
|
|
|
public double Salary { get; set; }
|
|
|
|
public int Id { get; private set; }
|
|
public List<int> Employees { get; private set; } = new List<int>();
|
|
|
|
public static Position? Create(PositionBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Position()
|
|
{
|
|
Id = model.Id,
|
|
PositionName = model.PositionName,
|
|
Salary = model.Salary
|
|
};
|
|
}
|
|
|
|
public static BsonDocument? CreateBSON(PositionBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new BsonDocument
|
|
{
|
|
{"PositionName", $"{model.PositionName}"},
|
|
{"Salary", $"{model.Salary}" },
|
|
{"EmployeesId", new BsonArray{}}
|
|
};
|
|
}
|
|
|
|
public static BsonDocument? UpdateBSON(PositionBindingModel? model, List<string> ids)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new BsonDocument
|
|
{
|
|
{"PositionName", $"{model.PositionName}"},
|
|
{"Salary", $"{model.Salary}" },
|
|
{"EmployeesId", new BsonArray(ids)}
|
|
};
|
|
}
|
|
}
|
|
}
|