Example #1
0
        public void CreateType(TypeBM model)
        {
            TypeOfWaybill element = context.TypeOfWaybills.FirstOrDefault(rec => rec.Type == model.Type);

            if (element != null)
            {
                throw new Exception("Уже есть type с таким name");
            }
            context.TypeOfWaybills.Add(new TypeOfWaybill
            {
                Type = model.Type
            });
            context.SaveChanges();
        }
Example #2
0
        public TypeBM GetElement(int id)
        {
            TypeOfWaybill element = context.TypeOfWaybills.FirstOrDefault(rec => rec.Id == id);

            if (element != null)
            {
                return(new TypeBM
                {
                    Id = element.Id,
                    Type = element.Type,
                    Waybills = element.Waybills
                });
            }
            throw new Exception("Элемент не найден");
        }