// GET api/users
        public HttpResponseMessage Get(int Id)
        {
            HttpResponseMessage    message     = new HttpResponseMessage();
            ApiError               apiError    = null;
            APIResponse            apiResponse = null;
            NSRetail_CloudEntities entities    = new NSRetail_CloudEntities();

            try
            {
                var userslist = (from users in entities.TBLUSERs
                                 join branch in entities.BRANCHes on users.BRANCHID equals branch.BRANCHID
                                 where users.USERID == Id && users.DELETEDDATE == null && branch.DELETEDDATE == null
                                 select new { users.USERID, users.USERNAME, users.FULLNAME, users.EMAIL, users.GENDER, branch.BRANCHID, branch.BRANCHNAME, branch.ISWAREHOUSE }).ToList();
                if (userslist.Count > 0)
                {
                    apiResponse = new APIResponse(userslist, null);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
                else
                {
                    apiError    = new ApiError("User Not Found", "201");
                    apiResponse = new APIResponse(null, apiError);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
            }

            catch (Exception ex)
            {
                apiError    = new ApiError("Exception: " + ex.Message, "500");
                apiResponse = new APIResponse(null, apiError);
                return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
            }
            return(message);
        }
示例#2
0
        public HttpResponseMessage Get()
        {
            HttpResponseMessage    message     = new HttpResponseMessage();
            ApiError               apiError    = null;
            APIResponse            apiResponse = null;
            NSRetail_CloudEntities entities    = new NSRetail_CloudEntities();

            try
            {
                var brancheslist = (from branches in entities.BRANCHes
                                    where branches.DELETEDDATE == null
                                    select new
                {
                    branches.BRANCHID,
                    branches.BRANCHNAME,
                    branches.BRANCHCODE
                }
                                    ).ToList();
                if (brancheslist.Count > 0)
                {
                    apiResponse = new APIResponse(brancheslist, null);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
            }
            catch (Exception ex)
            {
                apiError    = new ApiError("Exception: " + ex.Message, "500");
                apiResponse = new APIResponse(null, apiError);
                return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
            }
            return(message);
        }
        public HttpResponseMessage getItemName(string itemCode)
        {
            HttpResponseMessage    message     = new HttpResponseMessage();
            ApiError               apiError    = null;
            APIResponse            apiResponse = null;
            NSRetail_CloudEntities entities    = new NSRetail_CloudEntities();

            try
            {
                //var itemList = (from code in entities.ITEMCODEs
                //                join item in entities.ITEMs on code.ITEMID equals item.ITEMID
                //                where code.ITEMCODE1 == itemCode && code.DELETEDDATE == null && item.DELETEDDATE == null
                //                select new
                //                {
                //                    code.ITEMCODEID,
                //                    code.ITEMCODE1,
                //                    item.ITEMID,
                //                    item.ITEMNAME

                //                }).ToList();
                var itemList = (from price in entities.ITEMPRICEs
                                join code in entities.ITEMCODEs on price.ITEMCODEID equals code.ITEMCODEID
                                join item in entities.ITEMs on code.ITEMID equals item.ITEMID
                                where code.ITEMCODE1 == itemCode && code.DELETEDDATE == null && item.DELETEDDATE == null && price.DELETEDDATE == null
                                select new
                {
                    code.ITEMCODEID,
                    code.ITEMCODE1,
                    item.ITEMID,
                    item.ITEMNAME,
                    price.ITEMPRICEID,
                    price.MRP,
                    price.SALEPRICE
                }).ToList();
                if (itemList.Count > 0)
                {
                    apiResponse = new APIResponse(itemList, null);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
                else
                {
                    apiError    = new ApiError("No Sub Category / Product(s) found", "201");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            catch (Exception ex)
            {
                apiError    = new ApiError("Exception: " + ex.Message, "500");
                apiResponse = new APIResponse(null, apiError);
                return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
            }
            return(message);
        }
示例#4
0
        public HttpResponseMessage DeleteStockCounting([FromUri] int nStockCounting)
        {
            HttpResponseMessage message     = new HttpResponseMessage();
            ApiError            apiError    = null;
            APIResponse         apiResponse = null;

            using (NSRetail_CloudEntities entities = new NSRetail_CloudEntities())
            {
                try
                {
                    if (nStockCounting != null || nStockCounting != 0)
                    {
                        try
                        {
                            {
                                Nullable <int> output = entities.CLOUD_USP_D_STOCKCOUNTINGDETAIL(nStockCounting);
                                if (output == 1)
                                {
                                    apiResponse = new APIResponse(null);
                                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                                    return(message);
                                }
                                else
                                {
                                    apiError    = new ApiError("Record is not deleted", "202");
                                    apiResponse = new APIResponse(null, apiError);
                                    return(Request.CreateResponse(HttpStatusCode.BadRequest, apiResponse));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        apiError    = new ApiError("Some parameters missing", "202");
                        apiResponse = new APIResponse(null, apiError);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, apiResponse));
                    }
                }
                catch (Exception ex)
                {
                    apiError    = new ApiError("Exception: " + ex.Message, "500");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            return(message);
        }
        public List <TBLUSER> Login(string email, string password)
        {
            //HttpResponseMessage message = new HttpResponseMessage();

            using (NSRetail_CloudEntities entities = new NSRetail_CloudEntities())
            {
                string encryptpassword = AesBase64Wrapper.Encrypt(password);
                //entities.Configuration.ProxyCreationEnabled = false;

                var query = (from users in entities.TBLUSERs
                             //join roles in entities.Roles on users.RoleID equals roles.RoleID
                             //from prod2 in prodGroup
                             where users.USERNAME == email && users.PASSWORDSTRING == encryptpassword && users.DELETEDDATE == null
                             select users).ToList();

                return(query);
            }
        }
示例#6
0
        public HttpResponseMessage getBranchDetails(string userID)
        {
            HttpResponseMessage    message     = new HttpResponseMessage();
            ApiError               apiError    = null;
            APIResponse            apiResponse = null;
            NSRetail_CloudEntities entities    = new NSRetail_CloudEntities();

            try
            {
                string branchID = (from user in entities.TBLUSERs
                                   where user.USERID == Convert.ToInt32(userID)
                                   select new
                {
                    user.BRANCHID
                }).ToString();
                int nBranchID = Convert.ToInt32(branchID);

                var branchname = (from branch in entities.BRANCHes
                                  where branch.BRANCHID == nBranchID && branch.DELETEDDATE == null
                                  select new
                {
                    branch.BRANCHNAME
                }).ToList();

                if (branchname.Count > 0)
                {
                    apiResponse = new APIResponse(branchname, null);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
                else
                {
                    apiError    = new ApiError("No Sub Category / Product(s) found", "201");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            catch (Exception ex)
            {
                apiError    = new ApiError("Exception: " + ex.Message, "500");
                apiResponse = new APIResponse(null, apiError);
                return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
            }
            return(message);
        }
        public HttpResponseMessage getPriceDetails(int itemCodeid)
        {
            HttpResponseMessage    message     = new HttpResponseMessage();
            ApiError               apiError    = null;
            APIResponse            apiResponse = null;
            NSRetail_CloudEntities entities    = new NSRetail_CloudEntities();

            try
            {
                var itemList = (from price in entities.ITEMPRICEs
                                join code in entities.ITEMCODEs on price.ITEMCODEID equals code.ITEMCODEID
                                where price.ITEMCODEID == itemCodeid && price.DELETEDDATE == null && code.DELETEDDATE == null
                                select new
                {
                    price.ITEMCODEID,
                    price.ITEMPRICEID,
                    price.MRP,
                    price.SALEPRICE
                }).ToList();

                if (itemList.Count > 0)
                {
                    apiResponse = new APIResponse(itemList, null);
                    message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                }
                else
                {
                    apiError    = new ApiError("No Sub Category / Product(s) found", "201");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            catch (Exception ex)
            {
                apiError    = new ApiError("Exception: " + ex.Message, "500");
                apiResponse = new APIResponse(null, apiError);
                return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
            }
            return(message);
        }
示例#8
0
        public HttpResponseMessage Get(int stockCountDetailId, int userId, int branchId)
        {
            HttpResponseMessage message     = new HttpResponseMessage();
            ApiError            apiError    = null;
            APIResponse         apiResponse = null;

            try
            {
                using (NSRetail_CloudEntities entities = new NSRetail_CloudEntities())
                {
                    if (stockCountDetailId > 0)
                    {
                        var stockList = (from stockdetail in entities.CLOUD_STOCKCOUNTINGDETAIL
                                         join stockcount in entities.CLOUD_STOCKCOUNTING on stockdetail.STOCKCOUNTINGID equals stockcount.STOCKCOUNTINGID
                                         join price in entities.ITEMPRICEs on stockdetail.ITEMPRICEID equals price.ITEMPRICEID
                                         join code in entities.ITEMCODEs on price.ITEMCODEID equals code.ITEMCODEID
                                         join item in entities.ITEMs on code.ITEMID equals item.ITEMID
                                         where stockdetail.DELETEDDATE == null && price.DELETEDDATE == null && code.DELETEDDATE == null && item.DELETEDDATE == null &&
                                         stockdetail.STOCKCOUNTINGDETAILID == stockCountDetailId && stockcount.BRANCHID == branchId && stockcount.CREATEDBY == userId &&
                                         stockcount.STATUS != true
                                         select new
                        {
                            stockdetail.STOCKCOUNTINGDETAILID,
                            stockdetail.ITEMPRICEID,
                            stockdetail.QUANTITY,
                            stockdetail.STOCKCOUNTINGID,
                            price.MRP,
                            price.SALEPRICE,
                            code.ITEMCODE1,
                            item.ITEMNAME
                        }).ToList();
                        if (stockList.Count > 0)
                        {
                            apiResponse = new APIResponse(stockList, null);
                            message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                        }
                        else
                        {
                            apiError    = new ApiError("stock counting details are not found", "201");
                            apiResponse = new APIResponse(null, apiError);
                            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                        }
                    }
                    else
                    {
                        var stockList = (from stockdetail in entities.CLOUD_STOCKCOUNTINGDETAIL
                                         join stockcount in entities.CLOUD_STOCKCOUNTING on stockdetail.STOCKCOUNTINGID equals stockcount.STOCKCOUNTINGID
                                         join price in entities.ITEMPRICEs on stockdetail.ITEMPRICEID equals price.ITEMPRICEID
                                         join code in entities.ITEMCODEs on price.ITEMCODEID equals code.ITEMCODEID
                                         join item in entities.ITEMs on code.ITEMID equals item.ITEMID
                                         where stockdetail.DELETEDDATE == null && price.DELETEDDATE == null && code.DELETEDDATE == null && item.DELETEDDATE == null &&
                                         stockcount.BRANCHID == branchId && stockcount.CREATEDBY == userId && stockcount.STATUS != true
                                         select new
                        {
                            stockdetail.STOCKCOUNTINGDETAILID,
                            stockdetail.ITEMPRICEID,
                            stockdetail.QUANTITY,
                            stockdetail.STOCKCOUNTINGID,
                            price.MRP,
                            price.SALEPRICE,
                            code.ITEMCODE1,
                            item.ITEMNAME
                        }).ToList();
                        if (stockList.Count > 0)
                        {
                            apiResponse = new APIResponse(stockList, null);
                            message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                        }
                        else
                        {
                            apiError    = new ApiError("stock counting details are not found", "201");
                            apiResponse = new APIResponse(null, apiError);
                            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(message);
        }
示例#9
0
        public HttpResponseMessage InsertStockCounting([FromUri] int stockCountingID, [FromUri] int stockCountDetailId, [FromUri] int branchId, [FromUri] int userId,
                                                       [FromUri] int itemPriceId, [FromUri] int quantity)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            ApiError            apiError = null;
            APIResponse         apiResponse = null;
            Nullable <int>      nStockCountOutput = 0, nStockCountDetailOutput = 0;
            DateTime            dtCreatedDate = DateTime.Now;

            using (NSRetail_CloudEntities entities = new NSRetail_CloudEntities())
            {
                try
                {
                    if (branchId != 0 && userId != 0 && itemPriceId != 0 && quantity != 0)
                    {
                        try
                        {
                            //string paramValue = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
                            //DataTable dt = (DataTable)JsonConvert.DeserializeObject(paramValue, (typeof(DataTable)));
                            if (stockCountingID == 0)
                            {
                                nStockCountOutput = entities.CLOUD_USP_CU_STOCKCOUNTING(stockCountingID, branchId, userId, dtCreatedDate).FirstOrDefault();

                                if (nStockCountOutput != 0)
                                {
                                    nStockCountDetailOutput = entities.CLOUD_USP_CU_STOCKCOUNTINGDETAIL(stockCountDetailId, nStockCountOutput, itemPriceId, quantity, dtCreatedDate).FirstOrDefault();
                                }
                            }
                            else
                            {
                                nStockCountDetailOutput = entities.CLOUD_USP_CU_STOCKCOUNTINGDETAIL(stockCountDetailId, stockCountingID, itemPriceId, quantity, dtCreatedDate).FirstOrDefault();
                            }



                            if (nStockCountDetailOutput != 0)
                            {
                                apiResponse = new APIResponse(null);
                                message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                            }
                            else
                            {
                                apiError    = new ApiError("Some parameters are missing", "202");
                                apiResponse = new APIResponse(null, apiError);
                                return(Request.CreateResponse(HttpStatusCode.NoContent, apiResponse));
                            }
                            return(message);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        apiError    = new ApiError("Some parameters are missing", "202");
                        apiResponse = new APIResponse(null, apiError);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, apiResponse));
                    }
                }
                catch (Exception ex)
                {
                    apiError    = new ApiError("Exception: " + ex.Message, "500");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            return(message);
        }
示例#10
0
        public HttpResponseMessage UpdateStatus([FromUri] int nStockCounting)
        {
            HttpResponseMessage message     = new HttpResponseMessage();
            ApiError            apiError    = null;
            APIResponse         apiResponse = null;

            using (NSRetail_CloudEntities entities = new NSRetail_CloudEntities())
            {
                try
                {
                    if (nStockCounting != null || nStockCounting != 0)
                    {
                        try
                        {
                            // FIRST create a blank object
                            CLOUD_STOCKCOUNTING sc = entities.CLOUD_STOCKCOUNTING.Create();

                            // SECOND set the ID
                            sc.STOCKCOUNTINGID = nStockCounting;

                            // THIRD attach the thing (id is not marked as modified)
                            entities.CLOUD_STOCKCOUNTING.Attach(sc);

                            // FOURTH set the fields you want updated.
                            sc.STATUS = true;

                            // FIFTH save that thing
                            Nullable <int> output = entities.SaveChanges();
                            if (output == 1)
                            {
                                apiResponse = new APIResponse(null);
                                message     = Request.CreateResponse(HttpStatusCode.OK, apiResponse);
                                return(message);
                            }
                            else
                            {
                                apiError    = new ApiError("Record is not deleted", "202");
                                apiResponse = new APIResponse(null, apiError);
                                return(Request.CreateResponse(HttpStatusCode.BadRequest, apiResponse));
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        apiError    = new ApiError("Some parameters missing", "202");
                        apiResponse = new APIResponse(null, apiError);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, apiResponse));
                    }
                }
                catch (Exception ex)
                {
                    apiError    = new ApiError("Exception: " + ex.Message, "500");
                    apiResponse = new APIResponse(null, apiError);
                    return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                }
            }
            return(message);
        }