Example #1
0
        public ProgressStatus AddToMyFlyght([FromForm] AddtoFlightList addtoFlightList)
        {
            var result = new ProgressStatus();

            try
            {
                string Custumerid = User.Claims.First(u => u.Type == "Customer").Value;
                var    Userobj    = _customer.FindById(Convert.ToInt32(Custumerid));
                if (Userobj != null)
                {
                    if (_flight.FindById(addtoFlightList.Flightid) != null)
                    {
                        AirPortModel.Models.CustomerFlight customerFlightobj = new AirPortModel.Models.CustomerFlight();
                        customerFlightobj.CustomerId = Userobj.Id;
                        customerFlightobj.FlightId   = addtoFlightList.Flightid;
                        if (_customerFlight.Insert(customerFlightobj) != 0)
                        {
                            result = new ProgressStatus {
                                Number = 1, Title = "Update Successful", Message = " با موفقیت به لیست پرواز من اضافه شد"
                            };
                        }
                        else
                        {
                            result = new ProgressStatus {
                                Number = 4, Title = "Update Successful", Message = " با خطا مواجه شد"
                            };
                        }
                    }
                    else
                    {
                        result = new ProgressStatus {
                            Number = 2, Title = "Update Successful", Message = "شناسه پرواز نا معتبر"
                        };
                    }
                }
                else
                {
                    result = new ProgressStatus {
                        Number = 3, Title = "Update Successful", Message = "توکن نا معتبر"
                    };
                }

                return(result);
            }
            catch (Exception ex)
            {
                result = new ProgressStatus {
                    Number = 0, Title = "UnhandledError", Message = ex.Message
                };
                return(result);
            }
        }
Example #2
0
 public ProgressStatus Update(AirPortModel.Models.CustomerFlight obj)
 {
     try
     {
         obj.LastUpdate = DateTime.Now.Date;
         _db.CustomerFlight.Update(obj);
         _db.SaveChanges();
         var result = new ProgressStatus {
             Number = 1, Title = "Update Successful", Message = "CustomerFlight Has been Update"
         };
         return(result);
     }
     catch (Exception ex)
     {
         var result = new ProgressStatus {
             Number = 0, Title = "Update Error", Message = "CustomerFlight  can't be Update"
         };
         return(result);
     }
 }
Example #3
0
 public int Insert(AirPortModel.Models.CustomerFlight obj)
 {
     try
     {
         if (_db.CustomerFlight.FirstOrDefault(x => x.FlightId.Equals(obj.FlightId) && x.CustomerId.Equals(obj.CustomerId)) == null)
         {
             obj.DateCreate = DateTime.Now;
             obj.LastUpdate = DateTime.Now;
             obj.IsDelete   = false;
             _db.CustomerFlight.Add(obj);
             _db.SaveChanges();
             return(obj.Id);
         }
         else
         {
             return(0);
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }