Ejemplo n.º 1
0
        public Responce UpdateWell(Guid wellId, string number)
        {
            try
            {
                Скважины well = db.Скважины.Find(wellId);
                well.Номер           = number;
                db.Entry(well).State = EntityState.Modified;
                db.SaveChangesAsync();

                return(Responce.CreateOkRespond());
            }
            catch (Exception e)
            {
                return(Responce.CreateErrorRespond(e.Message));
            }
        }
Ejemplo n.º 2
0
        public Responce DeleteWell(Guid wellId)
        {
            try
            {
                Скважины well = db.Скважины.Find(wellId);
                if (!well.Добыча.Any())
                {
                    db.Скважины.Remove(well);
                    db.SaveChanges();

                    return(Responce.CreateOkRespond());
                }
                else
                {
                    return(Responce.CreateErrorRespond("Сначала нужно удалить связанные Добычи."));
                }
            }
            catch (Exception e)
            {
                return(Responce.CreateErrorRespond(e.Message));
            }
        }
Ejemplo n.º 3
0
        public Responce CreateWell(Guid depositId, string number, string type, int depth, string drillingDate)
        {
            try
            {
                Скважины well = new Скважины
                {
                    Номер            = number,
                    Глубина          = depth,
                    Тип              = type,
                    Дата_бурения     = drillingDate.GetDate(),
                    ID_Месторождения = depositId
                };

                db.Скважины.Add(well);

                db.SaveChangesAsync();
                return(Responce.CreateOkRespond());
            }
            catch (Exception e)
            {
                return(Responce.CreateErrorRespond(e.Message));
            }
        }