コード例 #1
0
        public bool PayOrder(string orderId)
        {
            var jobRequest = _db.JobRequests.Where(x => x.Id.ToString() == orderId).FirstOrDefault();

            if (jobRequest != null)
            {
                jobRequest.IsPaymentDone = true;
                _db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        //public bool HasPrice(long subCatId)
        //{
        //    bool status = false;
        //    try
        //    {
        //        status = _db.SubCategories.Where(x => x.Id == subCatId).FirstOrDefault().Category.HasPrice??false;
        //    }
        //    catch (Exception ex)
        //    {
        //    }
        //    return status;
        //}

        public bool AddUpdateCategory(CategoryViewModel model)
        {
            bool status = false;

            try
            {
                if (model.Id != 0)
                {
                    var catData = _db.Categories.Where(x => x.Id == model.Id).FirstOrDefault();
                    if (catData != null)
                    {
                        var validName = _db.Categories.Where(x => x.Name.ToLower().Trim() ==
                                                             model.Name.ToLower().Trim() && x.Id != model.Id).FirstOrDefault();
                        if (validName != null)
                        {
                            message = Resource.service_name_already_exists;
                        }
                        else
                        {
                            catData.Name                = model.Name;
                            catData.Name_French         = model.Name_French;
                            catData.Name_Hebrew         = model.Name_Hebrew;
                            catData.Name_Russian        = model.Name_Russian;
                            catData.Description         = model.Description;
                            catData.Description_French  = model.Description_French;
                            catData.Description_Hebrew  = model.Description_Hebrew;
                            catData.Description_Russian = model.Description_Russian;
                            catData.Picture             = !string.IsNullOrEmpty(model.Picture) ? model.Picture : catData.Picture;
                            catData.Icon                = !string.IsNullOrEmpty(model.Icon) ? model.Icon : catData.Icon;
                            //catData.HasPrice = model.HasPrice;
                            catData.ForWorkers   = model.ForWorkers;
                            catData.DisplayOrder = model.DisplayOrder;
                            catData.ModifiedDate = DateTime.Now;
                            _db.SaveChanges();
                            status  = true;
                            message = Resource.service_update_success;
                        }
                    }
                    else
                    {
                        message = Resource.service_not_exists;
                    }
                }
                else
                {
                    var validName = _db.Categories.Where(x => x.Name.ToLower().Trim() ==
                                                         model.Name.ToLower().Trim()).FirstOrDefault();
                    if (validName != null)
                    {
                        message = Resource.service_name_already_exists;
                    }
                    else
                    {
                        Category category = new Category();
                        category.CreatedDate = DateTime.Now;
                        category.IsActive    = true;
                        //category.HasPrice = model.HasPrice;
                        category.ForWorkers          = model.ForWorkers;
                        category.Name                = model.Name;
                        category.Name_French         = model.Name_French;
                        category.Name_Hebrew         = model.Name_Hebrew;
                        category.Name_Russian        = model.Name_Russian;
                        category.Description         = model.Description;
                        category.Description_French  = model.Description_French;
                        category.Description_Hebrew  = model.Description_Hebrew;
                        category.Description_Russian = model.Description_Russian;
                        category.Picture             = model.Picture;
                        category.Icon                = model.Icon;
                        category.DisplayOrder        = model.DisplayOrder;
                        _db.Categories.Add(category);
                        _db.SaveChanges();

                        status  = true;
                        message = Resource.service_add_success;
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(status);
        }