Exemple #1
0
        public HttpResponseMessage Post([FromBody] Models.supplier_type objSupplierType, long?created_by)
        {
            try
            {
                if (string.IsNullOrEmpty(objSupplierType.supplier_type_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Supplier Type  is Empty"
                    }, formatter));
                }

                else
                {
                    if (_supplierTypeRepository.CheckDuplicateSupplierType(objSupplierType.supplier_type_name))
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "warning", msg = "Supplier Type Already Exists"
                        }, formatter));
                    }

                    else
                    {
                        supplier_type insertSupplierType = new supplier_type
                        {
                            supplier_type_name = objSupplierType.supplier_type_name,
                            created_by         = objSupplierType.created_by,
                            created_date       = DateTime.Now,
                            is_deleted         = objSupplierType.is_deleted = false,
                            is_active          = objSupplierType.is_active = true
                        };

                        bool saveSupplierType = _supplierTypeRepository.AddSupplierType(insertSupplierType, created_by);

                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "success", msg = "Supplier Type save successfully"
                        }, formatter));
                    }
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
 public bool DeleteSupplierType(long supplier_type_id, long?updated_by)
 {
     try
     {
         supplier_type objSupplierType = _entities.supplier_type.FirstOrDefault(st => st.supplier_type_id == supplier_type_id);
         objSupplierType.is_deleted   = true;
         objSupplierType.updated_by   = updated_by;
         objSupplierType.updated_date = DateTime.Now;
         _entities.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        public bool EditSupplierType(supplier_type objSupplierType, long?updated_by)
        {
            try
            {
                supplier_type objFindId = _entities.supplier_type.Find(objSupplierType.supplier_type_id);
                objFindId.supplier_type_name = objSupplierType.supplier_type_name;
                objFindId.updated_by         = updated_by;
                objFindId.updated_date       = DateTime.Now;
                objFindId.is_deleted         = objSupplierType.is_deleted = false;
                objFindId.is_active          = objSupplierType.is_active;

                _entities.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public bool AddSupplierType(supplier_type objSupplierType, long?created_by)
 {
     try
     {
         supplier_type insertSupplierType = new supplier_type
         {
             supplier_type_name = objSupplierType.supplier_type_name,
             created_by         = objSupplierType.created_by,
             created_date       = DateTime.Now,
             is_deleted         = objSupplierType.is_deleted = false,
             is_active          = objSupplierType.is_active = true
         };
         _entities.supplier_type.Add(insertSupplierType);
         _entities.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #5
0
        public HttpResponseMessage Put([FromBody] Models.supplier_type objSupplierType, long?updated_by)
        {
            try
            {
                if (string.IsNullOrEmpty(objSupplierType.supplier_type_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Supplier Type  is Empty"
                    }, formatter));
                }

                else
                {
                    //if (_supplierTypeRepository.CheckDuplicateSupplierType(objSupplierType.supplier_type_name))
                    //{
                    //    var formatter = RequestFormat.JsonFormaterString();
                    //    return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Supplier Type Already Exists" }, formatter);
                    //}
                    //else
                    //{
                    supplier_type editSupplierType = new supplier_type
                    {
                        supplier_type_id   = objSupplierType.supplier_type_id,
                        supplier_type_name = objSupplierType.supplier_type_name,
                        updated_by         = objSupplierType.updated_by,
                        updated_date       = DateTime.Now,
                        is_deleted         = objSupplierType.is_deleted = false,
                        is_active          = objSupplierType.is_active
                    };

                    bool supplierTypeUpdate = _supplierTypeRepository.EditSupplierType(editSupplierType, updated_by);

                    if (supplierTypeUpdate == true)
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK,
                                                      new Confirmation {
                            output = "success", msg = "Supplier Type Updated successfully"
                        }, formatter));
                    }

                    else
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK,
                                                      new Confirmation {
                            output = "success", msg = "Update Failed"
                        }, formatter));
                    }
                    //}
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }