예제 #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));
            }
        }
예제 #2
0
        public HttpResponseMessage Delete([FromBody] Models.supplier_type objSupplierType, long?updated_by)
        {
            try
            {
                bool objSupplier = _supplierTypeRepository.DeleteSupplierType(objSupplierType.supplier_type_id, updated_by);

                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Supplier Type Delete Successfully."
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
예제 #3
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));
            }
        }