Example #1
0
 public ProgressStatus Modify(int id, bool isdone)
 {
     AirPortModel.Models.FlightToDo dodo = new AirPortModel.Models.FlightToDo();
     dodo = _db.FlightToDos.FirstOrDefault(x => x.id.Equals(id));
     if (dodo != null)
     {
         dodo.IsDon = isdone;
     }
     try
     {
         _db.FlightToDos.Attach(dodo);
         _db.Entry(dodo).Property(x => x.IsDon).IsModified = true;
         _db.SaveChanges();
         var result = new ProgressStatus {
             Number = 1, Title = "Update Successful", Message = "FlightToDo Has been Update"
         };
         return(result);
     }
     catch (Exception ex)
     {
         var result = new ProgressStatus {
             Number = 0, Title = "Update Error", Message = ex.Message
         };
         return(result);
     }
 }
Example #2
0
 public int Insert(AirPortModel.Models.FlightToDo obj)
 {
     try
     {
         obj.DateCreate = DateTime.Now;
         obj.LastUpdate = DateTime.Now;
         obj.IsDelete   = false;
         _db.FlightToDos.Add(obj);
         _db.SaveChanges();
         return(obj.id);
     }
     catch (Exception ex)
     {
         _ = ex.Message;
         return(0);
     }
 }
Example #3
0
        public ProgressStatus AddToDo([FromForm] ToDoViewModel toDoViewModel)
        {
            var Result = new ProgressStatus();

            try
            {
                string customerid = User.Claims.First(x => x.Type.Equals("Customer")).Value;
                if (_customer.FindById(Convert.ToInt32(customerid)) != null)
                {
                    AirPortModel.Models.FlightToDo Todoobj = new AirPortModel.Models.FlightToDo();
                    Todoobj.Title       = toDoViewModel.Title;
                    Todoobj.Description = toDoViewModel.Description;
                    Todoobj.FlightId    = toDoViewModel.Flight;
                    Todoobj.IsDon       = false;
                    Todoobj.CustomerId  = Convert.ToInt32(customerid);
                    if (_flighttodo.Insert(Todoobj).Equals(0))
                    {
                        Result = new ProgressStatus {
                            Message = " ثبت با موفقیت انجام نشد", Number = 1, Title = "ToDo Registerd Successfully !"
                        };
                        return(Result);
                    }
                    else
                    {
                        Result = new ProgressStatus {
                            Message = " ثبت با موفقیت انجام شد", Number = 2, Title = "ToDo not Registerd !"
                        };
                        return(Result);
                    }
                }
                else
                {
                    Result = new ProgressStatus {
                        Message = "کاربری با این ایمیل موجود نیست", Number = 3, Title = "Email not Registerd"
                    };
                    return(Result);
                }
            }
            catch (Exception ex)
            {
                Result = new ProgressStatus {
                    Message = ex.Message, Number = 0, Title = "unhandled Error !"
                };
                return(Result);
            }
        }
Example #4
0
 public ProgressStatus Update(AirPortModel.Models.FlightToDo obj)
 {
     try
     {
         obj.LastUpdate = DateTime.Now.Date;
         _db.FlightToDos.Update(obj);
         _db.SaveChanges();
         var result = new ProgressStatus {
             Number = 1, Title = "Update Successful", Message = "FlightToDo Has been Update"
         };
         return(result);
     }
     catch (Exception ex)
     {
         var result = new ProgressStatus {
             Number = 0, Title = "Update Error", Message = ex.Message
         };
         return(result);
     }
 }